package net.optix.ip.vo
{
	import com.adobe.cairngorm.vo.IValueObject;

	[Bindable]
	public class InventionVO extends Object implements IValueObject
	{
		
		public var fileNames:String;
		
		public var inventionID:int;
		public var title:String;
		public var docket:String;
		public var firmDocket:String;
		public var clientID:int;
		public var inventorID:int;
		public var firmID:int;
		public var deadlineDate:String;
		public var bConfirm:int;
		public var sConfirm:String;
		public var practitionerID:int;
		public var type:int;
		public var status:int;
		public var keyWords:String;
		public var maxBudget:int;
		
		public var invented:String;
		public var published:String;
		public var created:String;
		public var pfDate:String;
		public var ufDate:String;
		public var renewalDate:String;
		public var targetDate:String;
		public var applicationNumber:String;
		public var clientDocket:String;
		public var goesAbandoned:String;
		public var fillingDueDate:String;
		public var issueDate:String;
		public var description:String;
		
		public var clientName:String;
		public var clientDescription:String;
		public var firmName:String;
		public var inventorName:String;
		
		public var practitionerName:String;
		public var inventorEmail:String;
		public var practitionerEmail:String;
		public var inventorPhone:String;
		public var practitionerPhone:String;
		
		public var bBid:int;
		public var requestBidDate:String;
		public var budget:int;
		public var typeName:String;
		public var statusName:String;
		
		public var lastActionDate:String;
		public var actionDueDate:String;
		public var value:int;
		
		public var fillingCost:Number;
		public var examinationCost:Number;
		public var totalCost:Number;
		
		public static var inventionType:Array	=	
			["Provisional Patent","Non-Provisional Utility Patent","CIP","Design Patent"];
		public static var inventionStatus:Array=	
			['Disclosure', 'File Provisional', 'File Non-provisional', 'Publish', 'Preparing Application', 
			'Inventor Review','Filed','Examination','Allowance','Issue','Abandon'];
			
		public static function purseInvention(value:XML):InventionVO
		{
			var invention:InventionVO	=	new InventionVO();
			
			try
			{
				invention.inventionID	=	value.InventionID;
				invention.title			=	value.Title;
				invention.docket		=	value.Docket;
				invention.firmDocket	=	value.FirmDocket;
				invention.clientID		=	value.ClientID;
				invention.inventorID	=	value.InventorID;
				invention.firmID		=	value.FirmID;
				invention.deadlineDate	=	value.DeadlineDate;
				invention.bConfirm		=	value.BConfirm;
				
				switch(invention.bConfirm)
				{
					case 0:
						invention.sConfirm	=	"NA";
						break;
					case -1:
						invention.sConfirm	=	"Decline";
						break;
					case 1:
						invention.sConfirm	=	"Accept";
						break;
					case 2:
						invention.sConfirm	=	"Returned";
						break;
					case 3:
						invention.sConfirm	=	"";
						break;
				}
				
				invention.practitionerID=	value.PractitionerID;
				invention.type			=	value.Type;
				invention.status		=	value.Status;
				invention.keyWords		=	value.KeyWords;			
				invention.maxBudget		=	value.MaxBudget;
				invention.invented		=	value.Invented;
				
				invention.published		=	value.Published;
				invention.created		=	value.Created;
				invention.pfDate		=	value.PFDate;
				invention.ufDate		=	value.UFDate;
				invention.renewalDate	=	value.RenewalDate;
				invention.targetDate	=	value.TargetDate;
				invention.applicationNumber=value.ApplicationNumber;
				invention.clientDocket	=	value.ClientDocket;
				invention.goesAbandoned	=	value.GoesAbandoned;
				invention.fillingDueDate=	value.FillingDueDate;
				invention.issueDate		=	value.IssueDate;
				invention.description	=	value.Description;
				invention.clientName	=	value.ClientName;
				invention.clientDescription=	value.ClientDescription;
				invention.firmName		=	value.FirmName;
				invention.inventorName	=	value.InventorFirstName+" "+value.InventorLastName;
				invention.practitionerName	=	value.PractitionerFirstName+" "+value.PractitionerLastName;
				invention.inventorEmail		=		value.InventorEmail;
				invention.practitionerEmail	=	value.PractitionerEmail;
				invention.inventorPhone		=	value.InventorPhone;
				invention.practitionerPhone	=	value.PractitionerPhone;
				invention.bBid				=	value.BBid;
				invention.requestBidDate	=	value.RequestBidDate;
				invention.lastActionDate	=	value.LastActionDate;
				
				invention.actionDueDate		=	value.ActionDueDate;
				
				invention.value				=	value.Value;
				
				invention.budget			=	value.Budget;
				if(invention.type == 0 && invention.status == 6)
				{
					invention.statusName	=	"Provisional Filed";
				}
				else
				{
					invention.statusName		=	InventionVO.inventionStatus[invention.status];
				}
				
				invention.typeName		=	InventionVO.inventionType[invention.type];
				if(invention.type == -1)
				{
					invention.typeName	=	"NA";
				}
				else
				{
					invention.typeName	=	InventionVO.inventionType[invention.type];
				}
				
				
				if(invention.published == '0000-00-00')
				{
					invention.published	=	'';
				}
				if(invention.pfDate == '0000-00-00')
				{
					invention.pfDate	=	'';
				}
				if(invention.ufDate == '0000-00-00')
				{
					invention.ufDate	=	'';
				}
				if(invention.renewalDate == '0000-00-00')
				{
					invention.renewalDate	=	'';
				}
				if(invention.targetDate == '0000-00-00')
				{
					invention.targetDate	=	'';
				}
				if(invention.fillingDueDate == '0000-00-00')
				{
					invention.fillingDueDate	=	'';
				}
				if(invention.issueDate == '0000-00-00')
				{
					invention.issueDate	=	'';
				}
				if(invention.lastActionDate == '0000-00-00')
				{
					invention.lastActionDate	=	'';
				}
				if(invention.actionDueDate == '0000-00-00')
				{
					invention.actionDueDate	=	'';
				}
				
				if(invention.lastActionDate	==	'')
				{
					invention.lastActionDate	=	invention.created;
				}
				invention.fillingCost	=	value.FillingCost;
				invention.examinationCost=	value.ExaminationCost;
				invention.totalCost		=	value.TotalCost;
				
				
			}
			catch(error:Error){trace(error);}
			
			return invention;
		}
	}
}